home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / os2 / mnicon.zip / MNICON.C < prev    next >
Text File  |  1993-02-21  |  6KB  |  207 lines

  1.  
  2. /*
  3.  * This file was generated by the SOM Compiler.
  4.  * FileName: MNIcon.c.
  5.  * Generated using:
  6.  *     SOM Precompiler spc: 1.22
  7.  *     SOM Emitter emitc: 1.24
  8.  */
  9.  
  10. /*
  11.  * MNIcon class release 1.0 (02/21/93) by Makoto Nagata
  12.  */
  13.  
  14. #define MNIcon_Class_Source
  15. #include "MNIcon.ih"
  16.  
  17. #include <stdlib.h>
  18. #include <string.h>
  19. #include <stdio.h>
  20.  
  21. #include <wpshadow.h>
  22.  
  23. /*******************************************************************************
  24.  
  25.     Class Data
  26.  
  27. *******************************************************************************/
  28.  
  29. char szClassName[] = "MNIcon";
  30. char szInstanceFilter[] = "*.ICO";
  31. char szInstanceType[] = "Icon";
  32.  
  33. /*******************************************************************************
  34.  
  35.     Get Original Object
  36.  
  37.     - if pObject is a shadow, returns the original
  38.  
  39. *******************************************************************************/
  40.  
  41. WPObject* GetOriginalObject(WPObject* pObject)
  42. {
  43.     if (pObject)
  44.     {
  45.         if (_somIsA(pObject, _WPShadow))
  46.         {
  47.             return _wpQueryShadowedObject(pObject, FALSE);
  48.         }
  49.     }
  50.  
  51.     return pObject;
  52. }
  53.  
  54. /*******************************************************************************
  55.  
  56.     _wpDragOver
  57.  
  58.     - objects are droppable only if it is an object other than MNIcon
  59.  
  60. *******************************************************************************/
  61.  
  62. #undef SOM_CurrentClass
  63. #define SOM_CurrentClass SOMInstance
  64.  
  65. SOM_Scope MRESULT   SOMLINK mnicon_wpDragOver(MNIcon *somSelf,
  66.         HWND hwndCnr,
  67.         PDRAGINFO pdrgInfo)
  68. {
  69.     PDRAGITEM pdrgItem;
  70.     ULONG ulIndex;
  71.     WPObject* object;
  72.  
  73.     /* MNIconData *somThis = MNIconGetData(somSelf); */
  74.     MNIconMethodDebug("MNIcon","mnicon_wpDragOver");
  75.  
  76.     for (ulIndex = 0; ulIndex < DrgQueryDragitemCount(pdrgInfo); ulIndex ++)
  77.     {
  78.         pdrgItem = DrgQueryDragitemPtr(pdrgInfo, ulIndex);
  79.  
  80.         if (!DrgVerifyRMF(pdrgItem, "DRM_OBJECT", "DRF_OBJECT"))
  81.         {
  82.             return MRFROM2SHORT(DOR_NEVERDROP, DO_UNKNOWN);
  83.         }
  84.         else
  85.         {
  86.             object = GetOriginalObject((WPObject *)OBJECT_FROM_PREC(pdrgItem->ulItemID));
  87.  
  88.             if ((!object) || (_somIsA(object, _MNIcon)))
  89.             {
  90.                 return MRFROM2SHORT(DOR_NEVERDROP, DO_UNKNOWN);
  91.             }
  92.         }
  93.     }
  94.  
  95.     return MRFROM2SHORT(DOR_DROP, DO_UNKNOWN);
  96. }
  97.  
  98. /*******************************************************************************
  99.  
  100.     _wpDrop
  101.  
  102.     - sets the icon of the dropped objects using _wpSetIconData
  103.     - uses fixed size buffer because _wpQueryIconData doesn't give me the size!
  104.     - works only if the IconData type is ICON_DATA (which is the case for *.ICO)
  105.  
  106. *******************************************************************************/
  107.  
  108. #define MAXICONINFO 8192
  109.  
  110. #undef SOM_CurrentClass
  111. #define SOM_CurrentClass SOMInstance
  112.  
  113. SOM_Scope MRESULT   SOMLINK mnicon_wpDrop(MNIcon *somSelf,
  114.         HWND hwndCnr,
  115.         PDRAGINFO pdrgInfo,
  116.         PDRAGITEM pdrgItem)
  117. {
  118.     WPObject* object;
  119.     PICONINFO pIconInfo;
  120.     ULONG ulSize;
  121.  
  122.     /* MNIconData *somThis = MNIconGetData(somSelf); */
  123.     MNIconMethodDebug("MNIcon","mnicon_wpDrop");
  124.  
  125.     if (DrgVerifyRMF(pdrgItem, "DRM_OBJECT", "DRF_OBJECT"))
  126.     {
  127.         object = GetOriginalObject((WPObject *)OBJECT_FROM_PREC(pdrgItem->ulItemID));
  128.  
  129.         if ((object) && (!_somIsA(object, _MNIcon)))
  130.         {
  131.             ulSize = MAXICONINFO;
  132.  
  133.             if (pIconInfo = (PICONINFO)_wpAllocMem(somSelf, ulSize, NULL))
  134.             {
  135.                 if (_wpQueryIconData(somSelf, pIconInfo))
  136.                 {
  137.                     if (pIconInfo->fFormat == ICON_DATA)
  138.                     {
  139.                         pIconInfo->cb = sizeof(ICONINFO) + pIconInfo->cbIconData;
  140.                         pIconInfo->pIconData = ((PBYTE)pIconInfo) + sizeof(ICONINFO);
  141.  
  142.                         _wpSetIconData(object, pIconInfo);
  143.                     }
  144.                 }
  145.                 _wpFreeMem(somSelf, (PBYTE)pIconInfo);
  146.             }
  147.         }
  148.     }
  149.  
  150.     return (parent_wpDrop(somSelf,hwndCnr,pdrgInfo,pdrgItem));
  151. }
  152.  
  153. /*******************************************************************************
  154.  
  155.     _wpclsQueryTitle
  156.  
  157. *******************************************************************************/
  158.  
  159. #undef SOM_CurrentClass
  160. #define SOM_CurrentClass SOMMeta
  161.  
  162. SOM_Scope PSZ   SOMLINK mniconM_wpclsQueryTitle(M_MNIcon *somSelf)
  163. {
  164.     /* M_MNIconData *somThis = M_MNIconGetData(somSelf); */
  165.     
  166.     M_MNIconMethodDebug("M_MNIcon","mniconM_wpclsQueryTitle");
  167.  
  168.     return szClassName;
  169. }
  170.  
  171. /*******************************************************************************
  172.  
  173.     _wpclsQueryInstanceFilter
  174.  
  175. *******************************************************************************/
  176.  
  177. #undef SOM_CurrentClass
  178. #define SOM_CurrentClass SOMMeta
  179.  
  180. SOM_Scope PSZ   SOMLINK mniconM_wpclsQueryInstanceFilter(M_MNIcon *somSelf)
  181. {
  182.     /* M_MNIconData *somThis = M_MNIconGetData(somSelf); */
  183.     
  184.     M_MNIconMethodDebug("M_MNIcon","mniconM_wpclsQueryInstanceFilter");
  185.  
  186.     return szInstanceFilter;
  187. }
  188.  
  189. /*******************************************************************************
  190.  
  191.     _wpclsQueryInstanceType
  192.  
  193. *******************************************************************************/
  194.  
  195. #undef SOM_CurrentClass
  196. #define SOM_CurrentClass SOMMeta
  197.  
  198. SOM_Scope PSZ   SOMLINK mniconM_wpclsQueryInstanceType(M_MNIcon *somSelf)
  199. {
  200.     /* M_MNIconData *somThis = M_MNIconGetData(somSelf); */
  201.     
  202.     M_MNIconMethodDebug("M_MNIcon","mniconM_wpclsQueryInstanceType");
  203.  
  204.     return szInstanceType;
  205. }
  206.  
  207.